package com.ferryc.controller;

import com.ferryc.entity.Stroage;
import com.ferryc.model.Result;
import com.ferryc.tcc.IStroageTccService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Ferry Chen on 2019/11/26.
 */
@RestController
@RequestMapping(value = "/tcc",produces = MediaType.APPLICATION_JSON_VALUE)
public class StroageTccController {

    @Autowired
    private IStroageTccService stroageTccService;


    @PostMapping("/consume")
    public Result consume(@RequestParam(value = "productId") String productId,
                          @RequestParam(value = "count") int count) {
        Stroage stroage = new Stroage();
        stroage.setProductId(productId);
        stroage.setCount(count);
        stroageTccService.consume(stroage);
        return Result.success("ok");
    }
}
